<?php
vendor ( 'weibooauth' );
class DemoAction extends Action {
	/**
    +----------------------------------------------------------
	 * 默认操作
    +----------------------------------------------------------
	 */
	public function index() {
		//    	echo 'Demo!';
		$c = new WeiboClient ( C ( 'WB_AKEY' ), C ( 'WB_SKEY' ), $_SESSION ['last_key'] ['oauth_token'], $_SESSION ['last_key'] ['oauth_token_secret'] );
		$me = $c->verify_credentials ();
		if (isset ( $_REQUEST ['pic'] )) {
			$rr = $c->upload ( $_REQUEST ['text'], $_REQUEST ['pic'] );
			if (isset ( $rr ['error'] )) {
				echo $rr ['error'];
			} else {
				echo '分享成功!';
			}
		}
		$this->assign ( 'me', $me );
		$this->display ();
	}
	/**
	 * 画图演示函数
	 */
	public function draw() {
		$a = $_REQUEST ['say1'];
		$b = $_REQUEST ['say2'];
		$image = imagecreatefromjpeg ( "./Public/images/vs.jpg" );
		$black = imageColorAllocate ( $image, 0, 0, 0 );
		$fontfile = './Public/font/STHUPO.TTF';
		$angle = 0; //倾斜度
		$size = 15;
		$png_1 = imagecreatefrompng ( "./Public/images/vs_1.png" );
		$png_2 = imagecreatefrompng ( "./Public/images/vs_2.png" );
		imagecopy ( $image, $png_1, 0, 0, 0, 0, 413, 400 );
		imagettftext ( $image, $size, $angle, 160, 40, $black, $fontfile, $a );
		imagecopy ( $image, $png_2, 0, 0, 0, 0, 413, 400 );
		imagettftext ( $image, $size, $angle, 160, 110, $black, $fontfile, $b );
		imagejpeg ( $image );
		header ( 'Content-type: image/jpg' );
		imagedestroy ( $image );
	}
	/**
	 * 空操作
	 */
	Public function _empty() {
		R ( 'Empty', 'index' );
	}
}
?>